package com.example.erp.utils;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 分页相关参数
 *
 * @author gxz
 */
public class ReqPageInfo implements Serializable {
    /**
     * 当前页码
     */
    @NotNull(message = "当前页码不能为空")
    private int currentPage;

    /**
     * 每页大小
     */
    @NotNull(message = "每页大小不能为空")
    private int pageSize;

    /**
     * 排序sql
     */
    private String sortBy;

    /**
     * 前端传入排序字段
     */
    private List<Map<String, String>> fieldList;

    public int getCurrentPage() {
        return currentPage <= 0 ? 1 : currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize <= 0 ? 10 : pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public String getSortBy() {
        return sortBy;
    }

    public void setSortBy(String sortBy) {
        this.sortBy = sortBy;
    }

    public List<Map<String, String>> getFieldList() {
        return fieldList;
    }

    public void setFieldList(List<Map<String, String>> fieldList) {
        this.fieldList = fieldList;
    }

    @Override
    public String toString() {
        return "ReqPageInfo{" + "currentPage=" + currentPage + ", pageSize=" + pageSize + ", sortBy='" + sortBy + '\'' + ", fieldList=" + fieldList + '}';
    }
}
